package com.cloudcross.ssp.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cloudcross.ssp.base.dao.GenericIBatisDao;
import com.cloudcross.ssp.common.utils.MapBuilder;
import com.cloudcross.ssp.common.utils.Pager;
import com.cloudcross.ssp.model.AdgroupZone;
import com.cloudcross.ssp.model.AdsVoEntity;
import com.cloudcross.ssp.model.MediaEntity;
import com.cloudcross.ssp.service.IWebsiteService;

@Service
public class WebsiteService implements IWebsiteService {

    @Autowired
    private GenericIBatisDao myBatisDao;

    @Override
    public List<MediaEntity> queryWebsiteByCondition(Map<String, Object> paramMap, Pager pager) {
        return this.myBatisDao.getList("websiteSqlMapper.queryWebisteList", paramMap);
    }

    @Override
    public List<MediaEntity> queryAppByCondition(Map<String, Object> paramMap, Pager pager) {
        return myBatisDao.getList("websiteSqlMapper.queryAppList", paramMap);
    }

    @Override
    public List<MediaEntity> queryAppAds(Map<String, Object> paramMap) {
        return myBatisDao.getList("websiteSqlMapper.queryAppAds", paramMap);
    }
    
    @Override
    public List<MediaEntity> queryManagementAds(Map<String, Object> paramMap) {
        return myBatisDao.getList("websiteSqlMapper.queryManagementAds", paramMap);
    }
    
    @Override
    public List<AdsVoEntity> queryAppAdsList(Map<String, Object> paramMap) {
        return myBatisDao.getList("websiteSqlMapper.queryAppAdsList", paramMap);
    }

    @Override
    public List<AdsVoEntity> queryManageAdsList(Map<String, Object> paramMap) {
        return myBatisDao.getList("websiteSqlMapper.queryManageAdsList", paramMap);
    }

    @Override
    public void deleteByGroupId(Long adGroupId) {
        myBatisDao.getList("websiteSqlMapper.deleteByGroupId", adGroupId);
    }

    @Override
    public void deleteAdxByGroupId(Long adGroupId) {
        myBatisDao.getList("websiteSqlMapper.deleteAdxByGroupId", adGroupId);
    }

    @Override
    public void insertGroupZone(List<AdgroupZone> zoneList) {
        myBatisDao.getList("websiteSqlMapper.insertGroupZone",
                MapBuilder.create(HashMap.class).add("zoneList", zoneList).map());
    }

    @Override
    public List<MediaEntity> queryAdxByCondition(Map<String, Object> condition, Pager pager) {
        return myBatisDao.getList("websiteSqlMapper.queryAdxList", condition);
    }

    @Override
    public List<MediaEntity> queryAdxAppAds(Map<String, Object> paramMap) {
        return myBatisDao.getList("websiteSqlMapper.queryAdxAppAds", paramMap);
    }
    
    @Override
    public List<AdsVoEntity> queryAdxAdsList(Map<String, Object> condition) {
        return myBatisDao.getList("websiteSqlMapper.queryAdxAdsList", condition);
    }

    @Override
    public List<AdsVoEntity> queryManageAdsByList(Map<String, Object> condition) {
        return myBatisDao.getList("websiteSqlMapper.queryManageAdsByList", condition);
    }

    @Override
    public List<AdsVoEntity> queryAppAdsByList(Map<String, Object> condition) {
        return myBatisDao.getList("websiteSqlMapper.queryAppAdsByList", condition);
    }
}
